package com.ysy.tz.mfg.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ysy.tz.core.utils.SQLUtils;
import com.ysy.tz.core.utils.SessionUtils;
import com.ysy.tz.mfg.dao.ArriveFactoryDao;
import com.ysy.tz.mfg.dto.ArriveFactoryDto;
import com.ysy.tz.mfg.entity.ArriveFactoryEntity;
import com.ysy.tz.mfg.entity.UserEntity;
import java.util.ArrayList;
import java.util.List;

public class ArriveFactoryService {
    public ArriveFactoryService() {
    }

    protected void finalize() throws Throwable {
        super.finalize();
        System.out.println("------------>>>> 清除了service!! ArriveFactoryService  ---------->>>");
    }

    public ArrayList<ArriveFactoryEntity> searchArriveFactorySum(ArriveFactoryDto condition) {
        return (ArrayList)SQLUtils.executeSQLWithReturn(ArriveFactoryDao.class, (arriveFactoryDao) -> {
            try {
                UserEntity currentUser = (UserEntity)SessionUtils.getAttribute(SessionUtils.CURRENT_USER);
                condition.setEnterpriseId(currentUser.getEnterpriseId());
                ArrayList<ArriveFactoryEntity> arriveFactoryEntities = arriveFactoryDao.sumForPage(condition);
                return arriveFactoryEntities;
            } catch (Exception var4) {
                var4.printStackTrace();
                return null;
            }
        });
    }

    public PageInfo<ArriveFactoryEntity> searchArriveFactoryList(ArriveFactoryDto condition) {
        return (PageInfo)SQLUtils.executeSQLWithReturn(ArriveFactoryDao.class, (arriveFactoryDao) -> {
            UserEntity currentUser = (UserEntity)SessionUtils.getAttribute(SessionUtils.CURRENT_USER);
            condition.setEnterpriseId(currentUser.getEnterpriseId());
            PageHelper.startPage(condition.getPageNum(), condition.getPageSize());

            try {
                List arriveFactoryEntities = arriveFactoryDao.listForPage(condition);
                PageInfo<ArriveFactoryEntity> result = new PageInfo(arriveFactoryEntities);
                return result;
            } catch (Exception var5) {
                var5.printStackTrace();
                return null;
            }
        });
    }
}
